quit -sim

echo "Compiling verilog modules..."
make

# Supresses message 3009 about timescale directives
# and message 7 about not finding appropiate ROMs for init
vsim -t ns -suppress 3009,7 zet.test_zet

add wave -label clk        -hex clk
add wave -label rst        -hex rst

add wave -label pc         -hex zet/pc
add wave -label st         -hex zet/core/fetch/state
add wave -label ns         -hex zet/core/fetch/next_state
add wave -label opcode     -hex zet/core/opcode
add wave -label modrm      -hex zet/core/modrm
add wave -label seq_addr   -hex zet/core/seq_addr
add wave -label end_seq    -hex zet/core/end_seq
add wave -label need_modrm -hex zet/core/need_modrm
add wave -label need_off   -hex zet/core/need_off
add wave -label off_size   -hex zet/core/off_size
add wave -label need_imm   -hex zet/core/need_imm
add wave -label imm_size   -hex zet/core/imm_size
add wave -label ir         -hex zet/core/ir
add wave -label imm        -hex zet/core/imm
add wave -label off        -hex zet/core/off

add wave -divider cache_line
add wave -label fetch/ip								-hex zet/core/exec/regfile/r\[15\]
add wave -label fetch/instr_length			-hex zet/core/fetch/instr_length
add wave -label core/opcode							-hex zet/core/opcode
add wave -label decode/op								-hex zet/core/decode/op
add wave -label decode/exec_st					-hex zet/core/decode/exec_st
add wave -label decode/imm_l						-hex zet/core/decode/imm_l
add wave -label fetch/imm_f							-hex zet/core/decode/imm_f		
add wave -label micro/imm_o							-hex zet/core/micro_data/imm_o
add wave -label cache_line							-hex zet/core/fetch/cache_line_data
add wave -label cpu_word_i							-hex zet/core/fetch/cpu_word_i
add wave -label new_data								-hex zet/core/fetch/new_data
add wave -label cpu_dat_i								-hex zet/core/cpu_dat_i
add wave -label fetch/state 						-hex zet/core/fetch/state
add wave -label fetch/next_state				-hex zet/core/fetch/next_state
add wave -label wb/cpu_dat_i						-hex test_zet/zet/wb_master/cpu_dat_i
add wave -label fetch/shift							-hex zet/core/fetch/shift_cache_line
add wave -label we_shift								-hex zet/core/fetch/cache_line/we_shift
add wave -label bytes_in_cache_line			-hex zet/core/fetch/bytes_in_cache_line
add wave -label cache_not_full					-hex zet/core/fetch/cache_line_not_full
add wave -label wr_cache								-hex zet/core/fetch/cache_line/we_data

add wave -divider DEBUG
add wave -label clk							-hex clk
add wave -label exec/b_imm			-hex zet/core/exec/b_imm
add wave -label exec/bus_b			-hex zet/core/exec/bus_b
add wave -label wb/cpu_adr_o		-hex zet/wb_master/cpu_adr_o
add wave -label wb/cpu_dat_i		-hex zet/wb_master/cpu_dat_i
add wave -label core/opcode			-hex zet/core/opcode
add wave -label fetch/state			-hex zet/core/fetch/state
add wave -label fetch/next_state	-hex zet/core/fetch/next_state
#add wave -label fetch/imm_l			-hex zet/core/fetch/imm_l
#add wave -label fetch/off_l			-hex zet/core/fetch/off_l
add wave -label fetch/opcode_l		-hex zet/core/fetch/opcode_l
add wave -label fethc/modrm_l		-hex zet/core/fetch/modrm_l
add wave -label nstate/end_instr	-hex zet/core/fetch/nstate/end_instr

add wave -divider fetch
#add wave -hex zet/core/fetch/*

add wave -divider regfile
add wave -label ax  -hex zet/core/exec/regfile/r\[0\]
add wave -label bx  -hex zet/core/exec/regfile/r\[3\]
add wave -label cx  -hex zet/core/exec/regfile/r\[1\]
add wave -label dx  -hex zet/core/exec/regfile/r\[2\]
add wave -label si  -hex zet/core/exec/regfile/r\[6\]
add wave -label di  -hex zet/core/exec/regfile/r\[7\]
add wave -label sp  -hex zet/core/exec/regfile/r\[4\]
add wave -label es  -hex zet/core/exec/regfile/r\[8\]
add wave -label cs  -hex zet/core/exec/regfile/r\[9\]
add wave -label ss  -hex zet/core/exec/regfile/r\[10\]
add wave -label ds  -hex zet/core/exec/regfile/r\[11\]
add wave -label ip  -hex zet/core/exec/regfile/r\[15\]
add wave -label tmp -hex zet/core/exec/regfile/r\[13\]
add wave -label d   -hex zet/core/exec/regfile/d\[15:0\]
add wave -label wr  -hex zet/core/exec/regfile/wr

add wave -divider wb_master
add wave -hex zet/wb_master/*
#add wave -label cpu_block -hex zet/cpu_block
#add wave -label stb       -hex stb
#add wave -label ack       -hex ack
#add wave -label adr       -hex adr
#add wave -label sel       -hex sel
#add wave -label dat_o     -hex dat_o
#add wave -label dat_i     -hex dat_i
#add wave -label we        -hex we
#add wave -label tga       -hex tga

#add wave -divider alu
#add wave -label x       -hex zet/core/exec/a
#add wave -label y       -hex zet/core/exec/bus_b
#add wave -label t       -hex zet/core/exec/alu/t
#add wave -label func    -hex zet/core/exec/alu/func
#add wave -label d       -hex zet/core/exec/regfile/d
#add wave -label addr_a  -hex zet/core/exec/regfile/addr_a
#add wave -label addr_d  -hex zet/core/exec/regfile/addr_d
#add wave -label wr      -hex zet/core/exec/regfile/wr
#add wave -label exec_st -hex zet/core/exec_st

add wave -divider nstate
add wave -hex zet/core/fetch/nstate/*

add wave -divider next_or_not
add wave -hex zet/core/fetch/next_or_not/*

add wave -divider decode
add wave -hex zet/core/decode/*

run 10us

